<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P213 9.3.4 【案例】内容查找与替换</title>
</head>

<body>
    <div>过滤前内容：<br>
        <textarea id="pre" rows="10" cols="40"></textarea>
        <input id="btn" type="button" value="过滤">
    </div>
    <div>过滤后内容：<br>
        <textarea id="res" rows="10" cols="40"></textarea>
    </div>
    <script>
        document.getElementById('btn').onclick = function () {
            var reg = /(bad)|[\u4e00-\u9fa5]/gi;
            var str = document.getElementById('pre').value;
            var newstr = str.replace(reg, '*');
            document.getElementById('res').innerHTML = newstr;
        };
    </script>
    <a href="../首页/page09.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>